﻿using System.Windows.Forms;

namespace Just4Devs.Vsirc.Addin.UI
{
	public partial class VsircChannelTab : VsircTab
	{
		public ListBox UserList
		{
			get
			{
				return usersListBox;
			}
		}

		public VsircChannelTab()
		{
			InitializeComponent();
		}

		public VsircChannelTab(string name, VsircScreenDirector screenDirector)
		{
			InitializeComponent();

			this.Name = name;
			this.Text = name;
			this.screenDirector = screenDirector;
		}

		public override void HandleMessage(ScreenMessage message)
		{
			if (message is TopicMessage)
				topicScreen.Text = "asdFASDF";

			chatScreen.HandleMessage(message);
		}

		public void SetUserList(string[] users)
		{
			usersListBox.UIThreadInvoke(() => usersListBox.DataSource = users);
		}

		void UserList_MouseDoubleClick(object sender, MouseEventArgs e)
		{
			var nick = usersListBox.SelectedItem.ToString();

			screenDirector.SelectTab(nick);
		}

		private VsircScreenDirector screenDirector;
	}
}
